Need help with this question [closed]

Posted by Jaime on Programmers See other posts from Programmers or by Jaime
Published on 2012-06-10T19:12:19Z Indexed on 2012/06/10 22:46 UTC
Read the original article Hit count: 307

Filed under:
|

Occasionally, multiplying the sizes of nested loops can give an overestimate for the Big-Oh running time. This result happens when an innermost loop is infrequently executed. Give the Big-O analysis of the running time. Implement the following code and run for several values of N, and compare your analysis with the actual running times.

for(int i = 1; i <= n; i++)
 for(int j = 1; j<=i * i; j++)
  if(j%i == 0)
   for(int k = 0; k < j; k++)
    sum++;

© Programmers or respective owner

Related posts about java

Related posts about complexity